package com.gis.biz.controller;

import com.gis.biz.service.IGeoSchoolService;
import com.gis.utils.JtsUtil;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import com.gis.common.model.ApiResult;
import com.gis.utils.ResultUtils;
import org.springframework.web.bind.annotation.*;
import com.gis.biz.entity.GeoSchool;

import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Magic1412
 * @since 2021-01-11
 */
@CrossOrigin
@Api(tags = "map")
@RestController
@RequestMapping("/biz/geo-school")
public class GeoSchoolController {

    @Autowired
    private IGeoSchoolService service;


    @GetMapping("/getGeoSchoolInfoById")
    public ApiResult<Map> getGeoSchoolById(@RequestParam Long id) {
        return ResultUtils.Success(service.getGeoById(id).get(0));
    }

    @GetMapping("/getGeoSchoolStatisticById")
    public ApiResult<GeoSchool> getGeoSchoolStatisticById() {
        return ResultUtils.Success(service.getGeoStatistic());
    }

    @GetMapping("/getGeoSchoolContainsPoint")
    public ApiResult<Map> getGeoContainsPoint(Double x, Double y){
        return ResultUtils.Success(service.getGeoContainsPoint(JtsUtil.newPoint(x,y)).get(0));
    }

}

